let vm = new Vue({
    el: '.main-content',
    data: function () {
        return {
            role: {},
            setting: {
                data: {
                    simpleData: {
                        enable: true,
                        idKey: "id",
                        pIdKey: "parentId"
                    },

                }, callback: {
                    onClick: this.onClick,
                    onRename: this.onRename,
                    onRemove: this.onRemove
                },
                edit: {
                    enable: true,
                    removeTitle: "删除",
                    renameTitle: "修改"
                },
                check:{
                    enable:true,
                    chkboxType: { "Y": "ps", "N": "ps" }
                }

            },
            nodes: []
        }

    },
    methods: {
        findById: function (id) {
            console.log("拿到id:" + id);
            axios.get("/guguanjia/role/get?id=" + id).then(function (resp) {
                vm.$data.role = resp.data;
            })
        },

        roleSelect: function (rid) {
            layer.obj = rid;
            layer.open({
                type: 2,
                title: false,
                area: ['70%', '70%'],
                content: '/guguanjia/role/roleSelect',
                end: () => {
                    if (layer.parentName != undefined && layer.parentName.length > 0) {
                        this.role.parentName = layer.parentName;
                    }
                }
            })
        },

        init: function () {
            //初始化nodes数据
            axios({
                url: "/guguanjia/resource/findAll"
            }).then(resp => {
                this.nodes = resp.data;
                this.nodes[this.nodes.length]={id:0,name:"菜单列表"};
                $.fn.zTree.init($("#select-treetreeSelectResEdit"), this.setting, this.nodes);
            }).catch(error => {
                layer.msg(error.message)
            })
        },

        cancel: function () {
            let index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index)
        }
    },
    created: function () {
        this.role = parent.layer;
        this.init()
    }
});

function abcdefgh(data) {
    vm.findById(data)
}